# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template import Template, Context
from django.template.loader import get_template
import datetime


def current_datetime_v2(request):
    now = datetime.datetime.now()
    t = Template("<html><body>It is now {{ current_date }}.</body></html>")
    html = t.render(Context({'current_date': now}))
    return HttpResponse(html)

def current_datetime_v3(request):
    now = datetime.datetime.now()
    # Simple way of using templates from the filesystem.
    # This is BAD because it doesn't account for missing files!
    fp = open('E:/PythonWorks/workspace/djcode/djbook2/templates/mytemplate.html')
    t = Template(fp.read())
    fp.close()
    html = t.render(Context({'current_date': now}))
    return HttpResponse(html)

def current_datetime_v4(request):
    now = datetime.datetime.now()
    t = get_template('current_datetime.html')
    html = t.render(Context({'current_date': now}))
    return HttpResponse(html)

def current_datetime_v5(request):
    now = datetime.datetime.now()
    return render_to_response('current_datetime.html', {'current_date': now})


def current_datetime_v6(request):
    now = datetime.datetime.now()
    return render_to_response('current_datetime.html', {'current_date': now})

def mypage(request):
    return render_to_response('mypage.html', {'current_section': 'NAV'})
